/**
 *  @author phi
 *  @memo   
 */
#pragma once

#include "tmlib.h"
#include "game-app-manager.h"

class FreeListTest : public Application
{
public :
    void initialize()
    {
        _freeList.x(15);
        _freeList.y(15);
        {
            tmlib::display::DisplayObject* child = NULL;
            for (s32 i=0; i<6; ++i) {
                for (s32 j=0; j<6; ++j) {
                    child = new tmlib::display::InteractiveObject();
                    _freeList.addItem(child);
                    child->x(30*i).y(30*j).width(20).height(20);
                }
            }
        }

        {
            tmlib::display::DisplayObject* child = NULL;
        
            child = new tmlib::display::DisplayObject();
            _freeList.addChild(child);
            child->x(0).y(0).width(10).height(10);
            child->setColor(1.0f, 0.0f, 0.0f, 1.0f);
            _freeList.setCursorObject(child)->setCursorPos(1);
        }

        {
            _gauge = new tmlib::display::SimpleGauge();
            _freeList.addChild(_gauge);
            _gauge->x(0).y(0).width(100).height(20);
            _gauge->setColor(0.0f, 1.0f, 1.0f, 1.0f);
            _gauge->value(6);
        }
    }

    void finalize()
    {
    }

    void update()
    {
        _freeList.update();

        if (tmlib::theKeyInfo.flags() & 0x0008) { _gauge->value(_gauge->value()+1); }
        if (tmlib::theKeyInfo.flags() & 0x0004) { _gauge->value(_gauge->value()-1); }
    }
    void draw()
    {
        _freeList.draw();
    }

private :
    tmlib::display::FreeList        _freeList;
    tmlib::display::SimpleGauge*    _gauge;
};


